<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noodp" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
        <title>Valine及Valine-Admin评论系统配置 - 难知如阴</title><meta name="Description" content="个人博客评论系统搭建"><meta property="og:title" content="Valine及Valine-Admin评论系统配置" />
<meta property="og:description" content="个人博客评论系统搭建" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://skydominate.gitee.io/valine/" /><meta property="og:image" content="https://skydominate.gitee.io/valine/featured-image-preview.jpg"/><meta property="article:section" content="posts" />
<meta property="article:published_time" content="2021-11-03T19:50:59+08:00" />
<meta property="article:modified_time" content="2021-11-04T17:01:59+08:00" />

<meta name="twitter:card" content="summary_large_image"/>
<meta name="twitter:image" content="https://skydominate.gitee.io/valine/featured-image-preview.jpg"/>
<meta name="twitter:title" content="Valine及Valine-Admin评论系统配置"/>
<meta name="twitter:description" content="个人博客评论系统搭建"/>
<meta name="application-name" content="难知如阴">
<meta name="apple-mobile-web-app-title" content="难知如阴"><meta name="theme-color" content="#ffffff"><meta name="msapplication-TileColor" content="#da532c"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
        <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
        <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5"><link rel="manifest" href="/site.webmanifest"><link rel="canonical" href="https://skydominate.gitee.io/valine/" /><link rel="prev" href="https://skydominate.gitee.io/theme-documentation-basics/" /><link rel="next" href="https://skydominate.gitee.io/synergy/" /><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.1/normalize.min.css"><link rel="stylesheet" href="/css/style.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.13.0/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css"><script type="application/ld+json">
    {
        "@context": "http://schema.org",
        "@type": "BlogPosting",
        "headline": "Valine及Valine-Admin评论系统配置",
        "inLanguage": "zh-CN",
        "mainEntityOfPage": {
            "@type": "WebPage",
            "@id": "https:\/\/skydominate.gitee.io\/valine\/"
        },"image": [{
                            "@type": "ImageObject",
                            "url": "https:\/\/skydominate.gitee.io\/valine\/featured-image-preview.jpg",
                            "width":  185 ,
                            "height":  80 
                        }],"genre": "posts","keywords": "博客, Valine, Valine-Admin, 教程","wordcount":  2751 ,
        "url": "https:\/\/skydominate.gitee.io\/valine\/","datePublished": "2021-11-03T19:50:59+08:00","dateModified": "2021-11-04T17:01:59+08:00","license": "This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.","publisher": {
            "@type": "Organization",
            "name": "Lioyd Shaw","logo": {
                    "@type": "ImageObject",
                    "url": "https:\/\/skydominate.gitee.io\/images\/shadow.jpg",
                    "width":  1024 ,
                    "height":  576 
                }},"author": {
                "@type": "Person",
                "name": "lizilong"
            },"description": "个人博客评论系统搭建"
    }
    </script></head>
    <body header-desktop="fixed" header-mobile="auto"><script type="text/javascript">(window.localStorage && localStorage.getItem('theme') ? localStorage.getItem('theme') === 'dark' : ('auto' === 'auto' ? window.matchMedia('(prefers-color-scheme: dark)').matches : 'auto' === 'dark')) && document.body.setAttribute('theme', 'dark');</script>

        <div id="mask"></div><div class="wrapper"><header class="desktop" id="header-desktop">
    <div class="header-wrapper">
        <div class="header-title">
            <a href="/" title="难知如阴"><span class="header-title-pre"><i class='fas fa-theater-masks fa-fw'></i></span>难知如阴</a>
        </div>
        <div class="menu">
            <div class="menu-inner"><a class="menu-item" href="/posts/"> 所有文章 </a><a class="menu-item" href="/tags/"> 标签 </a><a class="menu-item" href="/categories/"> 分类 </a><a class="menu-item" href="/categories/documentation/"> 文档 </a><a class="menu-item" href="/about/"> 关于 </a><a class="menu-item" href="https://github.com/dillonzq/LoveIt" title="GitHub" rel="noopener noreffer" target="_blank"><i class='fab fa-github fa-fw'></i>  </a><span class="menu-item delimiter"></span><a href="javascript:void(0);" class="menu-item language" title="选择语言">简体中文<i class="fas fa-chevron-right fa-fw"></i>
                        <select class="language-select" id="language-select-desktop" onchange="location = this.value;"><option value="/valine/" selected>简体中文</option></select>
                    </a><span class="menu-item search" id="search-desktop">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-desktop">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-desktop" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-desktop" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-desktop">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </span><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                    <i class="fas fa-adjust fa-fw"></i>
                </a>
            </div>
        </div>
    </div>
</header><header class="mobile" id="header-mobile">
    <div class="header-container">
        <div class="header-wrapper">
            <div class="header-title">
                <a href="/" title="难知如阴"><span class="header-title-pre"><i class='fas fa-theater-masks fa-fw'></i></span>难知如阴</a>
            </div>
            <div class="menu-toggle" id="menu-toggle-mobile">
                <span></span><span></span><span></span>
            </div>
        </div>
        <div class="menu" id="menu-mobile"><div class="search-wrapper">
                    <div class="search mobile" id="search-mobile">
                        <input type="text" placeholder="搜索文章标题或内容..." id="search-input-mobile">
                        <a href="javascript:void(0);" class="search-button search-toggle" id="search-toggle-mobile" title="搜索">
                            <i class="fas fa-search fa-fw"></i>
                        </a>
                        <a href="javascript:void(0);" class="search-button search-clear" id="search-clear-mobile" title="清空">
                            <i class="fas fa-times-circle fa-fw"></i>
                        </a>
                        <span class="search-button search-loading" id="search-loading-mobile">
                            <i class="fas fa-spinner fa-fw fa-spin"></i>
                        </span>
                    </div>
                    <a href="javascript:void(0);" class="search-cancel" id="search-cancel-mobile">
                        取消
                    </a>
                </div><a class="menu-item" href="/posts/" title="">所有文章</a><a class="menu-item" href="/tags/" title="">标签</a><a class="menu-item" href="/categories/" title="">分类</a><a class="menu-item" href="/categories/documentation/" title="">文档</a><a class="menu-item" href="/about/" title="">关于</a><a class="menu-item" href="https://github.com/dillonzq/LoveIt" title="GitHub" rel="noopener noreffer" target="_blank"><i class='fab fa-github fa-fw'></i></a><a href="javascript:void(0);" class="menu-item theme-switch" title="切换主题">
                <i class="fas fa-adjust fa-fw"></i>
            </a><a href="javascript:void(0);" class="menu-item" title="选择语言">简体中文<i class="fas fa-chevron-right fa-fw"></i>
                    <select class="language-select" onchange="location = this.value;"><option value="/valine/" selected>简体中文</option></select>
                </a></div>
    </div>
</header>
<div class="search-dropdown desktop">
    <div id="search-dropdown-desktop"></div>
</div>
<div class="search-dropdown mobile">
    <div id="search-dropdown-mobile"></div>
</div>
<main class="main">
                <div class="container"><div class="toc" id="toc-auto">
            <h2 class="toc-title">目录</h2>
            <div class="toc-content always-active" id="toc-content-auto"></div>
        </div><article class="page single"><h1 class="single-title animated flipInX">Valine及Valine-Admin评论系统配置</h1><div class="post-meta">
            <div class="post-meta-line"><span class="post-author"><a href="https://lizilong1993.gitee.io" title="Author" target="_blank" rel="noopener noreffer author" class="author"><i class="fas fa-user-circle fa-fw"></i>lizilong</a></span>&nbsp;<span class="post-category">收录于 <a href="/categories/documentation/"><i class="far fa-folder fa-fw"></i>文档</a></span></div>
            <div class="post-meta-line"><i class="far fa-calendar-alt fa-fw"></i>&nbsp;<time datetime="2021-11-03">2021-11-03</time>&nbsp;<i class="fas fa-pencil-alt fa-fw"></i>&nbsp;约 2751 字&nbsp;
                <i class="far fa-clock fa-fw"></i>&nbsp;预计阅读 6 分钟&nbsp;<span id="/valine/" class="leancloud_visitors" data-flag-title="Valine及Valine-Admin评论系统配置">
                        <i class="far fa-eye fa-fw"></i>&nbsp;<span class=leancloud-visitors-count></span>&nbsp;次阅读
                    </span>&nbsp;</div>
        </div><div class="details toc" id="toc-static"  kept="">
                <div class="details-summary toc-title">
                    <span>目录</span>
                    <span><i class="details-icon fas fa-angle-right"></i></span>
                </div>
                <div class="details-content toc-content" id="toc-content-static"><nav id="TableOfContents">
  <ul>
    <li><a href="#abstract">1 简介</a></li>
    <li><a href="#prepare">2 快速开始</a></li>
    <li><a href="#installation">3 Valine应用配置</a></li>
    <li><a href="#add">4 Valine-Admin</a>
      <ul>
        <li><a href="#41-简介">4.1 简介</a></li>
        <li><a href="#42-valine-admin部署">4.2 Valine-Admin部署</a></li>
        <li><a href="#43-后台管理功能">4.3 后台管理功能</a></li>
        <li><a href="#44-定时任务">4.4 定时任务</a></li>
      </ul>
    </li>
    <li><a href="#done">5 完成</a></li>
    <li><a href="#ref">参考资料</a></li>
  </ul>
</nav></div>
            </div><div class="content" id="content"><h2 id="abstract">1 简介</h2>
<p>Valine - 一款快速、简洁且高效的无后端评论系统。</p>
<p>Valine 诞生于2017年8月7日，是一款基于<a href="https://leancloud.cn/" target="_blank" rel="noopener noreffer">LeanCloud</a>的快速、简洁且高效的无后端评论系统。</p>
<p>理论上支持但不限于静态博客，目前已有<a href="https://github.com/xCss/Valine-docs/blob/master/hexo.html" target="_blank" rel="noopener noreffer">Hexo</a>、<a href="https://github.com/xCss/Valine-docs/blob/master/jekyll.html" target="_blank" rel="noopener noreffer">Jekyll</a>、<a href="http://typecho.org/" target="_blank" rel="noopener noreffer">Typecho</a>、<a href="https://gohugo.io/" target="_blank" rel="noopener noreffer">Hugo</a>、<a href="https://ghost.org/" target="_blank" rel="noopener noreffer">Ghost</a>、<a href="https://github.com/daidi/docsify-valine/" target="_blank" rel="noopener noreffer">Docsify</a> 等博客和文档程序在使用Valine。</p>
<p><strong>特性</strong>：</p>
<ul>
<li>快速</li>
<li>安全</li>
<li>Emoji 😉</li>
<li>无后端实现</li>
<li>MarkDown 全语法支持</li>
<li>轻量易用</li>
<li><a href="https://github.com/xCss/Valine-docs/blob/master/visitor.html" target="_blank" rel="noopener noreffer">文章阅读量统计</a> <code>v1.2.0+</code></li>
</ul>
<h2 id="prepare">2 快速开始</h2>
<ol>
<li>你需要<a href="https://console.leancloud.cn/register" target="_blank" rel="noopener noreffer">注册</a>并登录Leancloud。</li>
</ol>
<div class="details admonition note open">
        <div class="details-summary admonition-title">
            <i class="icon fas fa-pencil-alt fa-fw"></i>注意<i class="details-icon fas fa-angle-right fa-fw"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content">建议注册LeanCloud国际版<a href="https://us.leancloud.cn/login.html#/signup" target="_blank" rel="noopener noreffer">LeanCloud - Build better apps, faster</a>，这样就可以使用官方赠送的二级域名啦。</div>
        </div>
    </div>
<ol start="2">
<li>创建Valine应用，名称任意，例如<code>Valine</code></li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032015802.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032015802.png, https://gitee.com/lizilong1993/image/raw/master/202111032015802.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032015802.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032015802.png"
        title="image-20211103201542321" /></p>
<ol start="2">
<li>进入对应的应用，点击<code>设置</code> -&gt; <code>应用 Keys</code>，获取<code>AppID</code>和<code>AppKey</code></li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032017056.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032017056.png, https://gitee.com/lizilong1993/image/raw/master/202111032017056.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032017056.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032017056.png"
        title="image-20211103201705991" /></p>
<ol start="2">
<li>以Hugo主题配置文件为例，填入对应的地方</li>
</ol>
<p><img src="https://gitee.com/lizilong1993/image/raw/master/202111032018813.png" alt="image-20211103201826747" style="zoom:50%;" /></p>
<div class="details admonition tip">
        <div class="details-summary admonition-title">
            <i class="icon fas fa-lightbulb fa-fw"></i>Valine参数设置<i class="details-icon fas fa-angle-right fa-fw"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content"><p>可选参数有<a href="https://valine.js.org/configuration.html" target="_blank" rel="noopener noreffer">配置项 | Valine 一款快速、简洁且高效的无后端评论系统。</a>，部分参数配置如下：</p>
<table>
<thead>
<tr>
<th style="text-align:center">参数</th>
<th style="text-align:left">值</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">appId</td>
<td style="text-align:left">AppID</td>
</tr>
<tr>
<td style="text-align:center">appKey</td>
<td style="text-align:left">AppKey</td>
</tr>
<tr>
<td style="text-align:center">placeholder</td>
<td style="text-align:left">评论框提示文字</td>
</tr>
<tr>
<td style="text-align:center">avatar</td>
<td style="text-align:left"><strong>可选值：</strong><br/>- ' &lsquo;(空字符串)<br/>-  mp<br/>- identicon<br/>- monsterid<br/>- wavatar<br/>- retro<br/>- robohash<br/>- hide<br>具体参数含义请看<a href="https://valine.js.org/avatar.html" target="_blank" rel="noopener noreffer">头像配置</a>。</td>
</tr>
<tr>
<td style="text-align:center">meta</td>
<td style="text-align:left">默认值:<code>['nick','mail','link']</code></td>
</tr>
<tr>
<td style="text-align:center">pageSize</td>
<td style="text-align:left">评论列表分页，每页条数。</td>
</tr>
<tr>
<td style="text-align:center">lang</td>
<td style="text-align:left">默认值:<code>zh-CN</code>，可选值：<code>zh-CN</code>，<code>zh-TW</code>，<code>en</code>，<code>ja</code>。</td>
</tr>
<tr>
<td style="text-align:center">visitor</td>
<td style="text-align:left"><a href="https://valine.js.org/visitor.html" target="_blank" rel="noopener noreffer">文章访问量统计</a></td>
</tr>
<tr>
<td style="text-align:center">highlight</td>
<td style="text-align:left"><code>代码高亮</code>，默认开启，若不需要，请手动关闭</td>
</tr>
<tr>
<td style="text-align:center">avatarForce</td>
<td style="text-align:left">每次访问<code>强制</code>拉取最新的<code>评论列表头像</code>，不推荐设置为<code>true</code>，目前的<code>评论列表头像</code>会自动带上<code>Valine</code>的版本号</td>
</tr>
<tr>
<td style="text-align:center">recordIP</td>
<td style="text-align:left">是否记录评论者IP</td>
</tr>
<tr>
<td style="text-align:center">serverURLs</td>
<td style="text-align:left">默认值: <code>http[s]://[tab/us].avoscloud.com</code>，该配置适用于国内<code>自定义域名</code>用户, <code>海外版本</code>会自动检测(无需手动填写)</td>
</tr>
<tr>
<td style="text-align:center">emojiCDN</td>
<td style="text-align:left">设置<code>表情包CDN</code>，参考<a href="https://valine.js.org/emoji.html" target="_blank" rel="noopener noreffer">自定义表情</a></td>
</tr>
<tr>
<td style="text-align:center">emojiMaps</td>
<td style="text-align:left">设置<code>表情包映射</code>，参考<a href="https://valine.js.org/emoji.html" target="_blank" rel="noopener noreffer">自定义表情</a></td>
</tr>
<tr>
<td style="text-align:center">enableQQ</td>
<td style="text-align:left">是否启用<code>昵称框</code>自动获取<code>QQ昵称</code>和<code>QQ头像</code>, 默认关闭，需<code>博/网站主</code>主动启用</td>
</tr>
<tr>
<td style="text-align:center">requiredFields</td>
<td style="text-align:left">设置<code>必填项</code>，默认值: []，默认<code>匿名</code>，可选值：[&lsquo;nick&rsquo;]，[&lsquo;nick&rsquo;,&lsquo;mail&rsquo;]</td>
</tr>
</tbody>
</table>
</div>
        </div>
    </div>
<h2 id="installation">3 Valine应用配置</h2>
<ol>
<li>查看评论
点击 <code>存储 </code>-&gt; <code>结构化数据</code>，选择创建<code>Class</code>，名称<code>Comment</code>，其他保持默认，以后就可在此<code>Class</code>内查看</li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032045367.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032045367.png, https://gitee.com/lizilong1993/image/raw/master/202111032045367.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032045367.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032045367.png"
        title="image-20211103204537280" /></p>
<ol start="2">
<li>文章阅读量统计
点击 <code>存储 </code>-&gt; <code>结构化数据</code>，选择创建<code>Class</code>，名称<code>CounterCounter</code>，其他保持默认，以后就可在此<code>Class</code>内查看</li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032043906.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032043906.png, https://gitee.com/lizilong1993/image/raw/master/202111032043906.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032043906.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032043906.png"
        title="image-20211103204345812" /></p>
<h2 id="add">4 Valine-Admin</h2>
<h3 id="41-简介">4.1 简介</h3>
<p><a href="https://github.com/hongweifuture/Valine-Admin" target="_blank" rel="noopener noreffer">Valine-Admin</a> 项目是一个对 Valine 评论系统的拓展应用，可增强 Valine 的邮件通知功能。基于 Leancloud 的云引擎与云函数，主要实现<code>评论邮件通知</code>、<code>评论管理</code>、<code>自定义邮件通知模板</code>等功能，而且还可以提供<code>邮件通知站长 </code>和 <code>@ 通知 </code>的功能。</p>
<p><a href="https://github.com/hongweifuture/Valine-Admin/blob/master/%e9%ab%98%e7%ba%a7%e9%85%8d%e7%bd%ae.md#%e9%82%ae%e4%bb%b6%e9%80%9a%e7%9f%a5%e5%b1%95%e7%a4%ba" target="_blank" rel="noopener noreffer">Valine-Admin邮件通知展示</a></p>
<h3 id="42-valine-admin部署">4.2 Valine-Admin部署</h3>
<ol>
<li>需要确保 Valine 的基础功能是正常的，参考 Valine Docs。</li>
<li>进入 Leancloud 对应的 Valine 应用中。</li>
<li>点击 云引擎 -&gt; 设置 填写代码库：https://github.com/hongweifuture/Valine-Admin，保存</li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032052022.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032052022.png, https://gitee.com/lizilong1993/image/raw/master/202111032052022.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032052022.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032052022.png"
        title="代码库" /></p>
<ol start="4">
<li>设置自定义环境变量，需要设置云引擎的环境变量以提供必要的信息，变量参数参考下面的配置项</li>
</ol>
<table>
<thead>
<tr>
<th>变量</th>
<th>示例</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>SITE_NAME</td>
<td>Lizilong’s Blog</td>
<td>[必填] 网站名称</td>
</tr>
<tr>
<td>SITE_URL</td>
<td><a href="https://lizilong1993.gitee.io" target="_blank" rel="noopener noreffer">https://lizilong1993.gitee.io</a></td>
<td>[必填] 网站地址，<strong>最后不要加 <code>/</code></strong></td>
</tr>
<tr>
<td>SMTP_SERVICE</td>
<td>QQ</td>
<td>[必填] 邮件服务提供商，支持 QQ、163、126、Gmail 以及 <a href="https://nodemailer.com/smtp/well-known/#supported-services" target="_blank" rel="noopener noreffer">更多</a>。 &mdash; <em>如这里没有你使用的邮件提供商，请查看<a href="https://github.com/hongweifuture/Valine-Admin/blob/master/%e9%ab%98%e7%ba%a7%e9%85%8d%e7%bd%ae.md#%e8%87%aa%e5%ae%9a%e4%b9%89%e9%82%ae%e4%bb%b6%e6%9c%8d%e5%8a%a1%e5%99%a8" target="_blank" rel="noopener noreffer">自定义邮件服务器</a></em></td>
</tr>
<tr>
<td>SMTP_USER</td>
<td><a href="mailto:xxxx@qq.com" rel="">xxxx@qq.com</a></td>
<td>[必填] SMTP登录用户，一般为邮箱地址</td>
</tr>
<tr>
<td>SMTP_PASS</td>
<td>xxxx</td>
<td>[必填] SMTP登录密码，一般为授权码，而不是邮箱的登陆密码，请自行查询对应邮件服务商的获取方式</td>
</tr>
<tr>
<td>SENDER_NAME</td>
<td>Blog-评论提醒</td>
<td>[可选] 发件人</td>
</tr>
<tr>
<td>ADMIN_URL</td>
<td><a href="https://xxxx.avosapps.us/" target="_blank" rel="noopener noreffer">https://xxxx.avosapps.us/</a></td>
<td>[建议] 云引擎域名，用于自动唤醒</td>
</tr>
<tr>
<td>TO_EMAIL</td>
<td><a href="mailto:xxxxx@qq.com" rel="">xxxxx@qq.com</a></td>
<td>[可选] 指定站长收信邮箱，默认值为<code>SITE_USER</code>。用于 SMTP 发件人与站长收件人不一致的情况下使用。</td>
</tr>
<tr>
<td>TEMPLATE_NAME</td>
<td>rainbow</td>
<td>[可选] 通知邮件的模板（default和rainbow），参考高级功能</td>
</tr>
</tbody>
</table>
<ol start="5">
<li>点击 <code>云引擎</code> -&gt; <code>部署</code>，选择<code>Git源码部署</code>，分支或版本号输入master，下载最新依赖（可选），部署</li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032104883.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032104883.png, https://gitee.com/lizilong1993/image/raw/master/202111032104883.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032104883.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032104883.png"
        title="Git" /></p>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032104228.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032104228.png, https://gitee.com/lizilong1993/image/raw/master/202111032104228.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032104228.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032104228.png"
        title="master" /></p>
<h3 id="43-后台管理功能">4.3 后台管理功能</h3>
<ol>
<li>点击 <code>云引擎 </code>-&gt; <code>设置</code>，在Web主机域名位置点击申请，获取二级域名，现在的二级域名不支持自定义，如果想好记请参考高级功能</li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032106583.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032106583.png, https://gitee.com/lizilong1993/image/raw/master/202111032106583.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032106583.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032106583.png"
        title="image-20211103210628507" /></p>
<ol start="2">
<li>设置后台管理登录信息，点击 <code>存储 </code>-&gt; <code>结构化数据</code>，选择<code>_User</code> -&gt;<code> 添加行</code>，只需要填写<code>password</code>、<code>username</code>、<code>email</code>这三个字段即可, 使用 <code>email</code> 作为账号登陆、<code>password </code>作为账号密码、<code>username </code>任意即可。</li>
</ol>
<div class="details admonition warning open">
        <div class="details-summary admonition-title">
            <i class="icon fas fa-exclamation-triangle fa-fw"></i>注意<i class="details-icon fas fa-angle-right fa-fw"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content">为了安全考虑，此 email <strong>必须</strong>为配置中的 SMTP_USER 或 TO_EMAIL， 否则不允许登录。</div>
        </div>
    </div>
<ol start="3">
<li>此后，可以通过https://二级域名.leanapp.cn/管理评论。</li>
</ol>
<h3 id="44-定时任务">4.4 定时任务</h3>
<p>免费版的 LeanCloud 容器，是有强制性休眠策略的，不能 24 小时运行：</p>
<ul>
<li>
<p>每天必须休眠 6 个小时</p>
</li>
<li>
<p>30 分钟内没有外部请求，则休眠</p>
</li>
<li>
<p>休眠后如果有新的外部请求实例则马上启动（但激活时此次发送邮件会失败）。</p>
</li>
</ul>
<p>分析了一下上方的策略，如果不想付费的话，最佳使用方案就<strong>设置定时器</strong>，目前基于 LeanCloud 自带定时器实现了<strong>两种云函数定时任务</strong>：</p>
<ul>
<li>自动唤醒，定时访问Web APP二级域名防止云引擎休眠（推荐）</li>
<li>定时检查，每天定时检查24小时内漏发的邮件通知</li>
</ul>
<ol>
<li>首先需要添加环境变量，点击 云引擎 -&gt; 设置，配置自定义环境变量，变量名ADMIN_URL，变量值Web 主机域名，即二级域名地址，添加后重启容器环境变量才会生效</li>
</ol>
<p><img
        class="lazyload"
        src="/svg/loading.min.svg"
        data-src="https://gitee.com/lizilong1993/image/raw/master/202111032111907.png"
        data-srcset="https://gitee.com/lizilong1993/image/raw/master/202111032111907.png, https://gitee.com/lizilong1993/image/raw/master/202111032111907.png 1.5x, https://gitee.com/lizilong1993/image/raw/master/202111032111907.png 2x"
        data-sizes="auto"
        alt="https://gitee.com/lizilong1993/image/raw/master/202111032111907.png"
        title="image-20211103211141819" />2. 配置定时任务，击 云引擎 -&gt; 定时任务</p>
<ul>
<li>配置<strong>自动唤醒</strong>（推荐），<code>创建定时任务</code>，名称任意，生产环境选择<code>self-wake</code>云函数，Cron表达式填入<code>0 */20 7-23 * * ?</code>，表示每天 7 - 23 点每 20 分钟访问一次，这样可以保持每天的绝大多数时间邮件服务是正常的。</li>
<li>配置<strong>定时检查</strong>，<code>创建定时任务</code>，名称任意，生产环境选择<code>resend-mails</code>云函数，Cron表达式填入<code>0 0 8 * * ?</code>，表示每天早8点检查过去24小时内漏发的通知邮件并补发</li>
</ul>
<div class="details admonition warning open">
        <div class="details-summary admonition-title">
            <i class="icon fas fa-exclamation-triangle fa-fw"></i>注意<i class="details-icon fas fa-angle-right fa-fw"></i>
        </div>
        <div class="details-content">
            <div class="admonition-content"><p>Valine-admin由于Leancloud<code>标准版流控原因</code>，自动唤醒任务可能会<strong>失败</strong>，（升级版不会控流）详情：https://forum.leancloud.cn/t/topic/22595</p>
<p>这里介绍一个使用第三方计划任务网站<a href="https://cron-job.org/en/signup/" target="_blank" rel="noopener noreffer">cron-job</a>进行定时唤醒Valine-admin的方法。具体操作参考如下文章：</p>
<p><a href="https://blog.csdn.net/HCL_Lonely/article/details/106446183" target="_blank" rel="noopener noreffer">使用cron-job解决Valine-admin因流控原因自动唤醒失败的问题_HCL_Lonely的博客-CSDN博客</a></p>
</div>
        </div>
    </div>
<br>
<h2 id="done">5 完成</h2>
<p>至此基于Valine和Valine-Admin的个人博客评论功能已经完成搭建完成啦！<i class="far fa-laugh-beam"></i></p>
<p>觉得有帮助，麻烦顺手给我<a href="https://gitee.com/lizilong1993/lizilong1993" target="_blank" rel="noopener noreffer">点个Star</a>吧 or <a href="https://lizilong1993.gitee.io/about/" target="_blank" rel="noopener noreffer">Buy me a coffee</a></p>
<h2 id="ref">参考资料</h2>
<ul>
<li><a href="https://blog.csdn.net/z_johnny/article/details/104211572" target="_blank" rel="noopener noreffer">配合 Valine 评论系统使用的 Valine-Admin 及显示个性头像_Johnny&rsquo;s Lab-CSDN博客</a></li>
<li><a href="https://github.com/ZhaoqiangCn/Valine-Admin" target="_blank" rel="noopener noreffer">ZhaoqiangCn/Valine-Admin: 一个 Valine 的拓展应用，用来增强 Valine 的邮件通知。 (github.com)</a></li>
<li><a href="https://www.cnblogs.com/antmoe/p/12904118.html" target="_blank" rel="noopener noreffer">Valine评论之Valine-admin配置攻略 - antmoe - 博客园 (cnblogs.com)</a></li>
<li><a href="https://blog.csdn.net/HCL_Lonely/article/details/106446183" target="_blank" rel="noopener noreffer">使用cron-job解决Valine-admin因流控原因自动唤醒失败的问题_HCL_Lonely的博客-CSDN博客</a>。</li>
</ul></div><div class="post-footer" id="post-footer">
    <div class="post-info">
        <div class="post-info-line">
            <div class="post-info-mod">
                <span>更新于 2021-11-04</span>
            </div>
            <div class="post-info-license"></div>
        </div>
        <div class="post-info-line">
            <div class="post-info-md"><span>
                            <a class="link-to-markdown" href="/valine/index.md" target="_blank">阅读原始文档</a>
                        </span></div>
            <div class="post-info-share">
                <span></span>
            </div>
        </div>
    </div>

    <div class="post-info-more">
        <section class="post-tags"><i class="fas fa-tags fa-fw"></i>&nbsp;<a href="/tags/%E5%8D%9A%E5%AE%A2/">博客</a>,&nbsp;<a href="/tags/valine/">Valine</a>,&nbsp;<a href="/tags/valine-admin/">Valine-Admin</a>,&nbsp;<a href="/tags/%E6%95%99%E7%A8%8B/">教程</a></section>
        <section>
            <span><a href="javascript:void(0);" onclick="window.history.back();">返回</a></span>&nbsp;|&nbsp;<span><a href="/">主页</a></span>
        </section>
    </div>

    <div class="post-nav"><a href="/theme-documentation-basics/" class="prev" rel="prev" title="主题文档 - 基本概念"><i class="fas fa-angle-left fa-fw"></i>主题文档 - 基本概念</a>
            <a href="/synergy/" class="next" rel="next" title="[神器推荐]Synergy——类KVM的多电脑键盘鼠标共享工具">[神器推荐]Synergy——类KVM的多电脑键盘鼠标共享工具<i class="fas fa-angle-right fa-fw"></i></a></div>
</div>
<div id="comments"><div id="valine" class="comment"></div><noscript>
                Please enable JavaScript to view the comments powered by <a href="https://valine.js.org/">Valine</a>.
            </noscript></div></article></div>
            </main><footer class="footer">
        <div class="footer-container"><div class="footer-line">由 <a href="https://gohugo.io/" target="_blank" rel="noopener noreffer" title="Hugo 0.88.1">Hugo</a> 强力驱动 | 主题 - <a href="https://github.com/dillonzq/LoveIt" target="_blank" rel="noopener noreffer" title="LoveIt 0.2.10"><i class="far fa-kiss-wink-heart fa-fw"></i> LoveIt</a>
                </div><div class="footer-line"><i class="far fa-copyright fa-fw"></i><span itemprop="copyrightYear">2023</span><span class="author" itemprop="copyrightHolder">&nbsp;<a href="/" target="_blank">Lioyd Shaw</a></span>&nbsp;|&nbsp;<span class="license"><a rel="license external nofollow noopener noreffer" href="https://creativecommons.org/licenses/by-nc/4.0/" target="_blank">CC BY-NC 4.0</a></span></div>
        </div>
    </footer>
 


</div>

        <div id="fixed-buttons"><a href="#" id="back-to-top" class="fixed-button" title="回到顶部">
                <i class="fas fa-arrow-up fa-fw"></i>
            </a><a href="#" id="view-comments" class="fixed-button" title="查看评论">
                <i class="fas fa-comment fa-fw"></i>
            </a>
        </div><link rel="stylesheet" href="/lib/valine/valine.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery.js@1.2.0/dist/css/lightgallery.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/copy-tex.min.css"><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/smooth-scroll@16.1.3/dist/smooth-scroll.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/autocomplete.js@0.37.1/dist/autocomplete.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/algoliasearch@4.2.0/dist/algoliasearch-lite.umd.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lazysizes@5.2.2/lazysizes.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lightgallery.js@1.2.0/dist/js/lightgallery.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lg-thumbnail.js@1.2.0/dist/lg-thumbnail.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lg-zoom.js@1.2.0/dist/lg-zoom.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/copy-tex.min.js"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/mhchem.min.js"></script><script type="text/javascript">window.config={"code":{"copyTitle":"复制到剪贴板","maxShownLines":10},"comment":{"valine":{"appId":"uefnzaEGhgPRfPDaRNWQ3MF4-MdYXbMMI","appKey":"4aOKu9jSOSSr2sL3DAec7Rkn","avatar":"robohash","el":"#valine","emojiCDN":"https://cdn.jsdelivr.net/npm/emoji-datasource-google@5.0.1/img/google/64/","emojiMaps":{"100":"1f4af.png","alien":"1f47d.png","anger":"1f4a2.png","angry":"1f620.png","anguished":"1f627.png","astonished":"1f632.png","black_heart":"1f5a4.png","blue_heart":"1f499.png","blush":"1f60a.png","bomb":"1f4a3.png","boom":"1f4a5.png","broken_heart":"1f494.png","brown_heart":"1f90e.png","clown_face":"1f921.png","cold_face":"1f976.png","cold_sweat":"1f630.png","confounded":"1f616.png","confused":"1f615.png","cry":"1f622.png","crying_cat_face":"1f63f.png","cupid":"1f498.png","dash":"1f4a8.png","disappointed":"1f61e.png","disappointed_relieved":"1f625.png","dizzy":"1f4ab.png","dizzy_face":"1f635.png","drooling_face":"1f924.png","exploding_head":"1f92f.png","expressionless":"1f611.png","face_vomiting":"1f92e.png","face_with_cowboy_hat":"1f920.png","face_with_hand_over_mouth":"1f92d.png","face_with_head_bandage":"1f915.png","face_with_monocle":"1f9d0.png","face_with_raised_eyebrow":"1f928.png","face_with_rolling_eyes":"1f644.png","face_with_symbols_on_mouth":"1f92c.png","face_with_thermometer":"1f912.png","fearful":"1f628.png","flushed":"1f633.png","frowning":"1f626.png","ghost":"1f47b.png","gift_heart":"1f49d.png","green_heart":"1f49a.png","grimacing":"1f62c.png","grin":"1f601.png","grinning":"1f600.png","hankey":"1f4a9.png","hear_no_evil":"1f649.png","heart":"2764-fe0f.png","heart_decoration":"1f49f.png","heart_eyes":"1f60d.png","heart_eyes_cat":"1f63b.png","heartbeat":"1f493.png","heartpulse":"1f497.png","heavy_heart_exclamation_mark_ornament":"2763-fe0f.png","hole":"1f573-fe0f.png","hot_face":"1f975.png","hugging_face":"1f917.png","hushed":"1f62f.png","imp":"1f47f.png","innocent":"1f607.png","japanese_goblin":"1f47a.png","japanese_ogre":"1f479.png","joy":"1f602.png","joy_cat":"1f639.png","kiss":"1f48b.png","kissing":"1f617.png","kissing_cat":"1f63d.png","kissing_closed_eyes":"1f61a.png","kissing_heart":"1f618.png","kissing_smiling_eyes":"1f619.png","laughing":"1f606.png","left_speech_bubble":"1f5e8-fe0f.png","love_letter":"1f48c.png","lying_face":"1f925.png","mask":"1f637.png","money_mouth_face":"1f911.png","nauseated_face":"1f922.png","nerd_face":"1f913.png","neutral_face":"1f610.png","no_mouth":"1f636.png","open_mouth":"1f62e.png","orange_heart":"1f9e1.png","partying_face":"1f973.png","pensive":"1f614.png","persevere":"1f623.png","pleading_face":"1f97a.png","pouting_cat":"1f63e.png","purple_heart":"1f49c.png","rage":"1f621.png","relaxed":"263a-fe0f.png","relieved":"1f60c.png","revolving_hearts":"1f49e.png","right_anger_bubble":"1f5ef-fe0f.png","robot_face":"1f916.png","rolling_on_the_floor_laughing":"1f923.png","scream":"1f631.png","scream_cat":"1f640.png","see_no_evil":"1f648.png","shushing_face":"1f92b.png","skull":"1f480.png","skull_and_crossbones":"2620-fe0f.png","sleeping":"1f634.png","sleepy":"1f62a.png","slightly_frowning_face":"1f641.png","slightly_smiling_face":"1f642.png","smile":"1f604.png","smile_cat":"1f638.png","smiley":"1f603.png","smiley_cat":"1f63a.png","smiling_face_with_3_hearts":"1f970.png","smiling_imp":"1f608.png","smirk":"1f60f.png","smirk_cat":"1f63c.png","sneezing_face":"1f927.png","sob":"1f62d.png","space_invader":"1f47e.png","sparkling_heart":"1f496.png","speak_no_evil":"1f64a.png","speech_balloon":"1f4ac.png","star-struck":"1f929.png","stuck_out_tongue":"1f61b.png","stuck_out_tongue_closed_eyes":"1f61d.png","stuck_out_tongue_winking_eye":"1f61c.png","sunglasses":"1f60e.png","sweat":"1f613.png","sweat_drops":"1f4a6.png","sweat_smile":"1f605.png","thinking_face":"1f914.png","thought_balloon":"1f4ad.png","tired_face":"1f62b.png","triumph":"1f624.png","two_hearts":"1f495.png","unamused":"1f612.png","upside_down_face":"1f643.png","weary":"1f629.png","white_frowning_face":"2639-fe0f.png","white_heart":"1f90d.png","wink":"1f609.png","woozy_face":"1f974.png","worried":"1f61f.png","yawning_face":"1f971.png","yellow_heart":"1f49b.png","yum":"1f60b.png","zany_face":"1f92a.png","zipper_mouth_face":"1f910.png","zzz":"1f4a4.png"},"enableQQ":true,"highlight":true,"lang":"zh-cn","pageSize":10,"placeholder":"留一个友善的评论吧","recordIP":true,"visitor":true}},"lightGallery":{"actualSize":false,"exThumbImage":"data-thumbnail","hideBarsDelay":2000,"selector":".lightgallery","speed":400,"thumbContHeight":80,"thumbWidth":80,"thumbnail":true},"math":{"delimiters":[{"display":true,"left":"$$","right":"$$"},{"display":true,"left":"\\[","right":"\\]"},{"display":false,"left":"$","right":"$"},{"display":false,"left":"\\(","right":"\\)"}],"strict":false},"search":{"algoliaAppID":"PASDMWALPK","algoliaIndex":"index.zh-cn","algoliaSearchKey":"b42948e51daaa93df92381c8e2ac0f93","highlightTag":"em","maxResultLength":10,"noResultsFound":"没有找到结果","snippetLength":50,"type":"algolia"}};</script><script type="text/javascript" src="/js/theme.min.js"></script></body>
</html>
